<?php
$courseOwner = false;
$categoryConfig = Configure::read('category');
if (isset($userLogon['User']['id']) && $course['Course']['user_id'] == $userLogon['User']['id']) {
	$courseOwner = true;
}
$class = '';
if (isset($categoryConfig[$course['Category']['rank']]['class'])) {
	$class = $categoryConfig[$course['Category']['rank']]['class'];
}
?>
<?php if ($courseOwner):?>
<div id="courseOwner">
	<div class="menuBox">
		<h2>講師用管理ツール</h2>
		<ul>
			<li><?php echo $this->Html->link('クラスの詳細の編集、更新', array('controller' => 'course', 'action' => 'edit', $course['Course']['id']));?></li>
			<li><?php echo $this->Html->link('クラス開催日程の追加', array('controller' => 'courseDetail', 'action' => 'add', $course['Course']['id']));?></li>
			<li><?php echo $this->Html->link('クラス開催日程の管理ページ', array('controller' => 'courseDetail', 'action' => 'index', $course['Course']['id']));?></li>
			<li><?php echo $this->Html->link('クラスの削除', array('controller' => 'course', 'action' => 'cancel', $course['Course']['id']));?></li>
		</ul>
	</div>
</div>
<?php endif;?>
<!-- #mainColumns -->
<div id="mainColumns">
	<!-- .section -->
	<div class="section course <?php echo $class;?>">
		<h2 class="title"><?php echo $course['Course']['title'];?></h2>
		<ul class="imageList clearfix">
			<?php if ($course['Course']['course_image01']):?>
			<li class="main"><?php echo $this->Html->image(Configure::read('Course.upload_path_prefix').$course['Course']['course_image01'], array('alt' => '', 'id' => 'largeImage'));?></li>
			<?php endif;?>
			<?php if ($course['Course']['course_image01']):?>
			<li><a href="javascript:void(0);"><?php echo $this->Html->image(Configure::read('Course.upload_path_prefix').$course['Course']['course_image01'], array('alt' => '', 'class' => 'smallImage'));?></a></li>
			<?php endif;?>
			<?php if ($course['Course']['course_image02']):?>
			<li><a href="javascript:void(0);"><?php echo $this->Html->image(Configure::read('Course.upload_path_prefix').$course['Course']['course_image02'], array('alt' => '', 'class' => 'smallImage'));?></a></li>
			<?php endif;?>
			<?php if ($course['Course']['course_image03']):?>
			<li><a href="javascript:void(0);"><?php echo $this->Html->image(Configure::read('Course.upload_path_prefix').$course['Course']['course_image03'], array('alt' => '', 'class' => 'smallImage'));?></a></li>
			<?php endif;?>
		</ul>
		<h4 class="title3">クラスのご紹介</h4>
		<p class="description"><?php echo nl2br($course['Course']['description']);?></p>
		<h4 class="title3">こんな方を対象としています</h4>
		<p class="targetUser"><?php echo nl2br($course['Course']['target_user']);?></p>
	</div>
	<!-- /.section -->
	<div class="timeline section">
		<?php echo $this->element('comment/list', array('courseId' => $course['Course']['id'])); ?>
		<?php echo $this->element('review/list', array('courseId' => $course['Course']['id']));?>
	</div>
</div>
<!-- /#mainColumns -->
<!-- #subColumns -->
<div id="subColumns">
	<!-- .section -->
	<div class="section teacher">
		<h2 class="title2">講師紹介</h2>
		<div class="content">
			<a href="<?php echo $this->Html->url(array('controller' => 'profile', 'action' => 'view', $course['Profile']['user_id']));?>">
				<?php echo $course['Profile']['icon_image'] ? $this->Html->image(Configure::read('User.upload_path_prefix').$course['Profile']['icon_image'], array('class' => 'avatar', 'alt' => '')) : $this->Html->image('icon.jpg', array('alt' => '', 'class' => 'avatar'));?>
			</a>
			<h3 class="name"><a href="<?php echo $this->Html->url(array('controller' => 'profile', 'action' => 'view', $course['Profile']['user_id']));?>">
					<?php echo $this->User->getUsername($course);?>
			</a></h3>
			<p class="headline"><?php echo $course['Profile']['headline'];?></p>
			<?php $profile = $course['Profile']['description'];?>
			<?php if(strlen($profile) > 100):?>
				<p class="description clearfix"><?php echo mb_substr($profile, 0, 100) . '…';?></p>
				<?php else:?>
				<p class="description clearfix"><?php echo $profile;?></p>
			<?php endif;?>
			<ul class="links">
				<li><?php echo $this->Html->link('詳しいプロフィールを見る', array('controller' => 'profile', 'action' => 'view', $course['Profile']['user_id']));?></li>
				<?php if ($course['User']['facebook_user_id']):?>
				<li><?php echo $this->Html->link('facebook', 'http://www.facebook.com/people/@/'.$course['User']['facebook_user_id']);?></li>
				<?php endif;?>
			</ul>
		</div>
	</div>
	<!-- /.section -->
	<div class="section watchList" id="watchList">
	<?php echo $this->element('watch_section', array('teacherId' => $course['Course']['user_id'], 'isOwner' => $courseOwner));?>
	</div>
	<!-- .section -->
	<div class="section detail" id="jsCourseSchedule">
		<?php echo $this->element('course/schedule', array('isOwner' => $courseOwner));?>
	</div>
	<!-- /.section -->
	<div class="section">
		<h2 class="title2">タグ</h2>
		<?php if($tags[0]['Tag']['name'] != ''):?>
		<ul class="cloudTags clearfix">
			<?php foreach ($tags as $tag):?>
			<li><?php echo $this->Html->link($tag['Tag']['name'], array('controller' => 'course', 'action' => 'index', 'type' => 'tag', 'id' => $tag['Tag']['id']));?></li>
			<?php endforeach;?>
		</ul>
		<?php else:?>
		<p>まだタグが登録されていません。</p>
		<?php endif;?>
	</div>
	<?php echo $this->element('search');?>

		<?php echo $this->element('course/list', array(
		'title' => 'この講師の他のクラス',
		'listCourses' => $userCourses,
	));
		?>
		<?php echo $this->element('course/list', array(
		'title' => 'このカテゴリの他クラス',
		'listCourses' => $categoryCourses,
	));
		?>
		<?php echo $this->element('course/list', array(
		'title' => 'このエリアの他クラス',
		'listCourses' => $areaCourses,
	));
		?>
</div>
<!-- /#subColumns -->
<?php echo $this->element('top_link2');?>